package com.sunsoft.base.proc.dao;

import java.sql.Types;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.sunsoft.base.proc.base.IBaseDao;
import com.sunsoft.base.proc.base.IBaseDao.IProcParam;
import com.sunsoft.base.proc.base.IBaseDao.IProcResult;
import com.sunsoft.base.proc.base.IBaseDao.ProcParamType;

/**
 * 存储过程操作类
 */
@Component
public class ProcListDaoImpl implements IProcListDao {
	@Autowired
	private IBaseDao iBaseDao;
	<#list listProcBeans as listProcBeans>
	<#assign outStr="">
	<#list listProcBeans.listProcDetails as listProcDetails>
		<#if listProcDetails.mode == "IN">
		<#assign outStr=outStr + "${listProcDetails.javaType} ${listProcDetails.newName},">
		</#if>
	</#list>
	
	@Override
	public IProcResult ${listProcBeans.newName}(<#if outStr?length != 0>${outStr?substring(0,outStr?length-1)}</#if>) throws Exception {
		IProcParam proc_param = iBaseDao.getParamInstances();
		<#list listProcBeans.listProcDetails as listProcDetails>
		<#if listProcDetails.mode == "IN">
		proc_param.put(${listProcDetails.newName}, ProcParamType.IN, ${listProcDetails.sqlType});
		<#else>
		proc_param.put(null, ProcParamType.OUT, ${listProcDetails.outParamSqlType});
		</#if>
		</#list>
		IProcResult result = iBaseDao.callProcedure("${listProcBeans.name}", proc_param);
		return result;
	}
	</#list>
	
}
